#include <iostream>
using std::cout;
using std::endl;
//成员函数模板；
//提供一个comparator类，该类有一个函数能够比较提供的两个值是否相等
//模板在当前场景下就显得很有必要
class Comparator{
public:
#if 0
    bool compare(int x, int y){
        return x == y;
    }
#endif
    template <class T>
    bool compare(const T & t1, const T & t2);
};

template <class T>
bool Comparator::compare(const T & t1, const T & t2){
    return t1 == t2;
}

void test(){
    Comparator comp;
    cout << comp.compare(1, 2) << endl;
    cout << comp.compare(1.4, 1.4) << endl;
}

int main()
{
    test();
    return 0;
}

